primes :: [Integer]
primes = 2 : filter ( (==1) . length . primeFactors ) [3,5..]

primeFactors :: Integer -> [Integer]
primeFactors n = factor n primes
	where
	factor n (p:ps)
		| p*p > n		 = [n]
		| n `mod` p == 0 = p : factor ( n `div` p )	(p:ps)
		| otherwise		 = factor n ps
		
isPrime :: Integer -> Bool
isPrime n
	| n <= 1 	= False
	| otherwise =((length(primeFactors n)) == 1)

oddComposits = [a| a<-[5, 7..], (not.isPrime) a]

isSquare :: Integer -> Bool
isSquare x = x == ((^2).floor.sqrt.fromIntegral) x

rejected n = any isSquare $ map (\x->(n-x) `div` 2) $ takeWhile (<n) primes

euler_046 = head $ dropWhile rejected oddComposits